#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
##############################################################################
#
#
#         ___           ___           ___           ___
#        /  /\         /  /\         /  /\         /  /\
#       /  /::\       /  /:/_       /  /:/_       /  /::\
#      /  /:/\:\     /  /:/ /\     /  /:/ /\     /  /:/\:\
#     /  /:/~/:/    /  /:/ /:/_   /  /:/ /::\   /  /:/~/:/
#    /__/:/ /:/___ /__/:/ /:/ /\ /__/:/ /:/\:\ /__/:/ /:/
#    \  \:\/:::::/ \  \:\/:/ /:/ \  \:\/:/~/:/ \  \:\/:/
#     \  \::/~~~~   \  \::/ /:/   \  \::/ /:/   \  \::/
#      \  \:\        \  \:\/:/     \__\/ /:/     \  \:\
#       \  \:\        \  \::/        /__/:/       \  \:\
#        \__\/         \__\/         \__\/         \__\/
#
#
#
#
#   This file is part of ReSP.
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#
#
#   (c) Giovanni Beltrame, Luca Fossati
#       Giovanni.Beltrame@esa.int fossati@elet.polimi.it
#
##############################################################################


import os, sys

def build(bld):
    # Library holding the code for exceptions
    obj = bld.new_task_gen('cxx', 'cshlib')
    obj.source = """
        utils.cpp
    """
    obj.target = 'utils'
    obj.name = 'utils'

    # Library holding the code for the python converters
    obj = bld.new_task_gen('pypp')
    obj.source = """
        to_convert.hpp
    """
    obj.target = 'converters'
    obj.uselib = 'SYSTEMC_H BOOST BOOST_PYTHON'
    obj.uselib_local = 'systemc'
    obj.start_decls = 'converters'
    obj.custom_declaration_code= """
#include <systemc.h>

#include <map>
#include <string>
#include "python_converters.hpp"

bool interactiveSimulation;

namespace sandbox { namespace {

    void vector_string_converter(){
        resp::tuple_mapping<std::vector<std::string>, resp::variable_capacity_policy>();
    }

    void map_string_sctime_converter(){
        resp::dict_mapping<std::map<std::string, sc_time> >();
    }

    void map_int_double_converter(){
        resp::dict_mapping<std::map<int, double> >();
    }

    void map_uint_sctime_converter(){
        resp::dict_mapping<std::map<unsigned int, sc_time> >();
    }

    void init_module(){
        map_string_sctime_converter();
        map_uint_sctime_converter();
        map_int_double_converter();
        vector_string_converter();
    }

}} // namespace sandbox::<anonymous>
"""
    obj.custom_registration_code = '''sandbox::init_module();'''

    obj = bld.new_task_gen('pypp')                                            
    obj.source = """
        debugMemory.hpp
    """
    obj.target = 'debugmemory'
    obj.uselib = 'BOOST BOOST_PYTHON'
    obj.virtuality = True
    obj.start_decls = 'resp'
    obj.custom_code = """
decl = mb.global_ns.class_('DebugMemory')
decl.include()
"""
